package com.ruoyi.web.controller.system;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessStatus;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.Constans;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.HatchetAgent;
import com.ruoyi.system.domain.HatchetIssBank;
import com.ruoyi.system.domain.HatchetMerchant;
import com.ruoyi.system.domain.HatchetMerchantIncreaseLimit;
import com.ruoyi.system.domain.HatchetOrderPayment;
import com.ruoyi.system.service.IHatchetAgentService;
import com.ruoyi.system.service.IHatchetIssBankService;
import com.ruoyi.system.service.IHatchetMerchantIncreaseLimitService;
import com.ruoyi.system.service.IHatchetMerchantService;
import com.ruoyi.system.service.IHatchetOrderPaymentService;
import com.ruoyi.system.service.ISysDictDataService;

/**
 * 代理商对用户的操作
 * 
 * @author ruoyi
 * @date 2019-02-18
 */
@Controller
@RequestMapping("/system/hatchetMerchantForDLS")
public class HatchetMerchantForDLSController extends BaseController {
	private String prefix = "system/hatchetMerchant";

	@Autowired
	private IHatchetMerchantService hatchetMerchantService;
	@Autowired
	private IHatchetAgentService agentService;
	@Autowired
	private IHatchetAgentService hatchetAgentService;
	@Autowired
	private ISysDictDataService dictDataService;
	@Autowired
	private IHatchetOrderPaymentService  orderPaymentService;
	@Autowired
	private IHatchetMerchantIncreaseLimitService  limitService;
	@Autowired
	private IHatchetIssBankService  bankService;
	
	@RequiresPermissions("system:hatchetMerchant:view")
	@GetMapping("/{status}")
	public String hatchetMerchant(@PathVariable("status") Integer status) {
		if (status == 1) {
			return prefix + "/hatchetMerchantForDLS";
		} else if (status == 2) {
			return prefix + "/hatchetMerchantForDLS2";
		} else if (status == 3) {
			return prefix + "/hatchetMerchantForDLS3";
		}
		return null;
	}

	/**
	 * 代理商查询用户列表
	 */
	@RequiresPermissions("system:hatchetMerchant:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(HatchetMerchant hatchetMerchant) {
		String loginName = getLoginName();
		List<HatchetMerchant> list  = new ArrayList<>();
		HatchetAgent agent = new HatchetAgent();
		//设置level查询条件
		if(StringUtils.isNotEmpty(hatchetMerchant.getLEVEL())) {
			hatchetMerchant.setLEVEL("0"+hatchetMerchant.getLEVEL());
		}
		//判断用户是代理商 还是高级经纪人
		if(loginName.length()>8) {
			HatchetMerchant merchant = hatchetMerchantService.selectHatchetMerchantByNo(loginName);
			hatchetMerchant.setBorkerId(merchant.getID());
			if (StringUtils.isNotEmpty(hatchetMerchant.getAgentNo())
					|| StringUtils.isNotEmpty(hatchetMerchant.getAgentName())) {
				HatchetAgent paramAgent = new HatchetAgent();
				paramAgent.setAgentNo(hatchetMerchant.getAgentNo());
				paramAgent.setAgentName(hatchetMerchant.getAgentName());
				List<HatchetAgent> selectHatchetAgentByaction = hatchetAgentService.selectHatchetAgentByaction(paramAgent);
				// 根据前台传的代理商信息封装代理商查询条件（agentId）
				if (selectHatchetAgentByaction != null && selectHatchetAgentByaction.size() > 0) {
					String agentId = selectHatchetAgentByaction.get(0).getID();
					// 封装代理商的查询条件
					hatchetMerchant.setAgentId(agentId);
				} else {
					// 没有代理商 返回空
					return getDataTable(new ArrayList<>());
				}
			}
			startPage();
			list = hatchetMerchantService.selectHatchetMerchantForJLR(hatchetMerchant);
		} else {
			// 查询代理商自己的信息
			 agent = hatchetAgentService.selectHatchetAgentByNo(loginName);
			// 查询自己目录下的用户
			hatchetMerchant.setDepartmentCode(StringUtils.likeDepartmentCode(agent.getDepartmentCode()));
			hatchetMerchant.setAgentId(agent.getID());
			if (StringUtils.isNotEmpty(hatchetMerchant.getAgentNo())
					|| StringUtils.isNotEmpty(hatchetMerchant.getAgentName())) {
				HatchetAgent paramAgent = new HatchetAgent();
				paramAgent.setAgentNo(hatchetMerchant.getAgentNo());
				paramAgent.setAgentName(hatchetMerchant.getAgentName());
				List<HatchetAgent> selectHatchetAgentByaction = hatchetAgentService.selectHatchetAgentByaction(paramAgent);
				// 根据前台传的代理商信息封装代理商查询条件（agentId）
				if (selectHatchetAgentByaction != null && selectHatchetAgentByaction.size() > 0) {
					String agentId = selectHatchetAgentByaction.get(0).getID();
					// 封装代理商的查询条件
					hatchetMerchant.setParamAgentId(agentId);
				} else {
					// 没有代理商 返回空
					return getDataTable(new ArrayList<>());
				}
			}
			startPage();
			list = hatchetMerchantService.selectHatchetMerchantForDLS(hatchetMerchant);
		}
		
		for (HatchetMerchant hatchetMerchant2 : list) {
			//当用户等级为2  判断用户的升级经纪人时间是否为空  如果不为空就是“经理”对应level=4 为空就是“经理（未激活）”对应level=2
			if("2".equals(hatchetMerchant2.getLEVEL())) {
				if(StringUtils.isNotNull(hatchetMerchant2.getSubmitReexamineTime())) {
					hatchetMerchant2.setLEVEL("4");//新升级的经理
				}
			}
			if (hatchetMerchant2.getAgentId() != null) {
				HatchetAgent hatchetAgent = agentService.selectHatchetAgentById(hatchetMerchant2.getAgentId());
				if (StringUtils.isNotNull(hatchetAgent)) {
					hatchetMerchant2.setAgentName(hatchetAgent.getAgentName());
					hatchetMerchant2.setAgentNo(hatchetAgent.getAgentNo());
				}
			}
			// 推荐人名称
			if (hatchetMerchant2.getParentPhone() != null) {
				HatchetMerchant newMerchant = new HatchetMerchant();
				newMerchant.setPHONE(hatchetMerchant2.getParentPhone());
				List<HatchetMerchant> merlist = hatchetMerchantService.selectHatchetMerchantList(newMerchant);
				if (merlist.size() > 0) {
					hatchetMerchant2.setParentName(merlist.get(0).getMerchantCnName());
				}
			}
			// 银行卡加*
			if (StringUtils.isNotEmpty(hatchetMerchant2.getBankAccount())) {
				hatchetMerchant2.setBankAccount(StringUtils.idCardNoString(hatchetMerchant2.getBankAccount(),4));
			}
			// 身份证加*
			if (hatchetMerchant2.getIdCardNumber() != null) {
				hatchetMerchant2.setIdCardNumber(StringUtils.idCardNoString(hatchetMerchant2.getIdCardNumber(),4));
			}
			//手机号，推荐人手机号加密
//			hatchetMerchant2.setPHONE(StringUtils.idCardNoString(hatchetMerchant2.getPHONE(),3));
//			hatchetMerchant2.setParentPhone(StringUtils.idCardNoString(hatchetMerchant2.getParentPhone(),3));
			if (loginName.length()<8) {
				if (hatchetMerchant2.getAgentId().equals(agent.getID())) {
					hatchetMerchant2.setDirect("直接用户");
				} else {
					hatchetMerchant2.setDirect("间接用户");
				}
			}
			
			//查询用户活跃度 查询用户的最近完成的一次的订单
			HatchetOrderPayment orderPayment = new HatchetOrderPayment();
			orderPayment.setMerchantId(hatchetMerchant2.getID());
			orderPayment.setSTATUS("10B");
			List<HatchetOrderPayment> orderPaymentList = orderPaymentService.selectHatchetOrderPaymentList(orderPayment);
			if (StringUtils.isNotEmpty(orderPaymentList)) {
				Date completeTime = orderPaymentList.get(0).getCompleteTime();
				String liveness = DateUtils.formetaDiff(completeTime);
				hatchetMerchant2.setLiveness(liveness);
			}else {
				hatchetMerchant2.setLiveness("不活跃");
			}
			if(loginName.length()>8) {
				//借用moneyType 设置标识 这是 高级经纪人可以修改用户备注
				hatchetMerchant2.setMoneyType("y");
			}
			// //客户手机号加*
			// if (StringUtils.isNotEmpty(hatchetMerchant2.getPHONE())) {
			// hatchetMerchant2.setPHONE(StringUtils.phoneString(hatchetMerchant2.getPHONE()));
			// }
			// //推荐人手机号加*
			// if (StringUtils.isNotEmpty(hatchetMerchant2.getParentPhone())) {
			// hatchetMerchant2.setParentPhone((StringUtils.phoneString(hatchetMerchant2.getParentPhone())));
			// }
		}
		return getDataTable(list);
	}

	/**
	 * 跳转查看用户关系页面
	 * 
	 * @param 查看的代理商id
	 * @param mmap
	 * @return
	 */
	@RequiresPermissions("system:hatchetMerchant:detail")
	@GetMapping("/detailForDLS/{id}")
	public String toShowPage(@PathVariable("id") String id, ModelMap mmap) {
		// 查询代理商自己的信息
		HatchetAgent agent = hatchetAgentService.selectHatchetAgentByNo(getLoginName());
		HatchetMerchant merchant = hatchetMerchantService.selectHatchetMerchantById(id);
		// 如果不是直接用户，手机号加*
		if (!merchant.getAgentId().equals(agent.getID())) {
			merchant.setPHONE(StringUtils.phoneString(merchant.getPHONE()));
		}
		merchant.setParentPhone(StringUtils.phoneString(merchant.getParentPhone()));
		mmap.put("hatchetMerchant", merchant);
		return prefix + "/detailForDLS";
	}

	/**
	 * 代理商查看用户关系
	 * 
	 * @param 查看的代理商id
	 * @param mmap
	 * @return
	 */
	@RequiresPermissions("system:hatchetMerchant:list")
	@GetMapping("/showRelation")
	@ResponseBody
	public List<HatchetAgent> showRelation(String id) {
		// 获得登陆代理商用户id
		String loginNo = getLoginName();
		// 被查看的用户
		HatchetMerchant hatchetMerchant = hatchetMerchantService.selectHatchetMerchantById(id);
		List<HatchetAgent> agents = new ArrayList<HatchetAgent>();
		HatchetAgent agent1 = new HatchetAgent();
		agent1.setTYPE(getLevelName(hatchetMerchant));
		agent1.setAgentName(hatchetMerchant.getMerchantCnName());
		//查询该用户的信用卡列表
		HatchetMerchantIncreaseLimit limit = new HatchetMerchantIncreaseLimit();
		limit.setMerchantId(hatchetMerchant.getID());
		limit.setIncreaseLimitStatus("10B");//绑定正在使用的卡
		List<HatchetMerchantIncreaseLimit> limitList = limitService.selectHatchetMerchantIncreaseLimitList(limit);
		for (HatchetMerchantIncreaseLimit limit2 : limitList) {
			//卡号加密
			limit2.setBankAccount(StringUtils.idCardNoString(limit2.getBankAccount(),4));
			//银行名称
			HatchetIssBank bank = bankService.selectHatchetIssBankByBankCode(limit2.getBankName());
			limit2.setBankName(bank.getShortCnName());
		}
		agent1.setLimitList(limitList);//set用户的信用卡列表
		agents.add(agent1);
		
		
		// 查找该用户的推荐人
		List<HatchetMerchant> merchantParentTree = hatchetMerchantService.getMerchantParentTree(hatchetMerchant.getPHONE());
		merchantParentTree.remove(0);//删掉用户自己
		for (HatchetMerchant hatchetMerchant2 : merchantParentTree) {
			HatchetAgent agent2 = new HatchetAgent();
			agent2.setTYPE(getLevelName(hatchetMerchant2));
			agent2.setAgentName(hatchetMerchant2.getMerchantCnName());
			agents.add(agent2);
		}
		// 查询该用户的代理商
		HatchetAgent agent = hatchetAgentService.selectHatchetAgentById(hatchetMerchant.getAgentId());
		HatchetAgent parentAgent = hatchetAgentService.selectHatchetAgentByNo(loginNo);
		// 判断查询的代理商和父级代理商的关系
		if (agent.getID().equals(parentAgent.getID())) {
			agents.add(agent);
		} else {
			agents.add(agent);
			while (!agent.getParentId().equals(parentAgent.getID())) {
				agent = hatchetAgentService.selectHatchetAgentById(agent.getParentId());
				agents.add(agent);
				// 查询代理的父级代理和登陆的代理一致，就不再循环
			}
			agents.add(parentAgent);
		}
		for (HatchetAgent hatchetAgent : agents) {
			if ("免费用户".equals(hatchetAgent.getTYPE())||"经理(未激活)".equals(hatchetAgent.getTYPE())||
					"经理".equals(hatchetAgent.getTYPE())||"经理(原经纪人)".equals(hatchetAgent.getTYPE())) {
				continue;
			}
			
			// 高级合伙人 不从字典表里面查
			if (StringUtils.isNotEmpty(hatchetAgent.getTYPE()) && StringUtils.isNotEmpty(hatchetAgent.getLEVEL())
					&& "3".equals(hatchetAgent.getTYPE()) && "1".equals(hatchetAgent.getLEVEL())) {
				hatchetAgent.setTYPE("高级合伙人");
			} else {
				String type = dictDataService.selectDictLabel("agent_level", hatchetAgent.getTYPE());
				hatchetAgent.setTYPE(type);
			}
		}
		return agents;
	}
	private String getLevelName(HatchetMerchant merchant) {
		if (StringUtils.isEmpty(merchant.getLEVEL()) ||"1".equals(merchant.getLEVEL()) ) {
			return "免费用户";
		} else if ("2".equals(merchant.getLEVEL()) ) {
			if(StringUtils.isNull(merchant.getSubmitReexamineTime())){
				return "经理(未激活)";
			}else {
				return "经理";
			}
		}else if ("3".equals(merchant.getLEVEL())) {
			return"经理(原经纪人)";
		}
		return "";
	}
	
	
	/**
	 * 查询用户（为升级）
	 * 
	 * @param hatchetMerchant
	 *            用户
	 * @param agentId
	 *            代理商
	 * @return
	 */
	@RequiresPermissions("system:hatchetMerchant:list")
	@GetMapping("/queryMerchan")
	@ResponseBody
	public Map<String, Object> queryMerchan(HatchetMerchant hatchetMerchant) {
		HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
		Map<String, Object> map = new HashMap<>();
		if (StringUtils.isEmpty(hatchetMerchant.getPHONE())) {
			map.put("msg", "手机号不能为空");
			map.put("status", BusinessStatus.FAIL);
		} else {
			Map<String, Object> params = new HashMap<String, Object>();
			hatchetMerchant.setParams(params);
			List<HatchetMerchant> merchantList = hatchetMerchantService.selectHatchetMerchantList(hatchetMerchant);
			if (StringUtils.isEmpty(merchantList)) {
				map.put("msg", "该用户不存在");
				map.put("status", BusinessStatus.FAIL);
			} else if (merchantList.size() > 1) {
				map.put("msg", "该用户信息异常请联系客服处理");
				map.put("status", BusinessStatus.FAIL);
			} else {
				HatchetMerchant merchant = merchantList.get(0);// 待升级的用户
				if (StringUtils.isEmpty(merchant.getIdCardNumber()) ) {
					map.put("msg", "该用户未实名认证,请先认证后再升级");
					map.put("status", BusinessStatus.FAIL);
					return map;
				}
				/*if (StringUtils.isEmpty(merchant.getBankAccount())) {
					map.put("msg", "该用户未绑定储蓄卡,请通知用户先绑定储蓄卡后再升级");
					map.put("status", BusinessStatus.FAIL);
					return map;
				}*/
				// 给自己升级
				if (merchant.getIdCardNumber().equals(agent.getIdCardNo())) {
					// 升级经纪人所需升级码数量
					/*map.put("codeCount", hatchetMerchantService.getUpgradeCodeCountForJJR());*/
					map.put("hatchetMerchant", merchant);
					// 代理商剩余升级码数量
					map.put("fastCount", agent.getFastCount());
					map.put("status", BusinessStatus.SUCCESS);
					// 给直推用户升级
				} else {
					// 判断agentId用户的代理商id是否是自己
					if (!agent.getID().equals(merchant.getAgentId())) {
						map.put("msg", "该用户的代理商不是您");
						map.put("status", BusinessStatus.FAIL);
						return map;
					}
					// 通过身份证号查询代理商的用户身份
					HatchetMerchant paramMerchant = new HatchetMerchant();
					paramMerchant.setIdCardNumber(agent.getIdCardNo());
					List<HatchetMerchant> agentMerchantList = hatchetMerchantService
							.selectHatchetMerchantList(paramMerchant);
					boolean flag = false;
					// 一个身份证可能有多个用户账号
					if (StringUtils.isNotEmpty(agentMerchantList)) {
						// 判断待升级的用户的推荐人手机号是否和代理商的手机号一致
						for (HatchetMerchant hatchetMerchant2 : agentMerchantList) {
							// 如果代理商用户的手机号和带升级用户的推荐人手机号一致，说明是代理商的直推用户
							if (merchant.getParentPhone().equals(hatchetMerchant2.getPHONE())) {
								flag = true;
							}
						}
					}
					// 是直推用户
					if (flag) {
						// 升级经纪人所需升级码数量
						/*map.put("codeCount", hatchetMerchantService.getUpgradeCodeCountForJJR());*/
						map.put("hatchetMerchant", merchant);
						// 代理商剩余升级码数量
						map.put("fastCount", agent.getFastCount());
						map.put("status", BusinessStatus.SUCCESS);
					} else {
						map.put("msg", "该用户不是您的直推用户");
						map.put("status", BusinessStatus.FAIL);
					}
				}
			}
		}
		return map;
	}

	/**
	 * 升级用户为经纪人
	 * 
	 * @param hatchetMerchant
	 *            用户
	 * @param agentId
	 *            代理商
	 * @return
	 */
	@Log(title = "升级经纪人", businessType = BusinessType.UPDATE)
	@RequiresPermissions("system:hatchetMerchant:list")
	@PostMapping("/liftMerchant")
	@ResponseBody
	public Map<String, Object> liftMerchant(HatchetMerchant hatchetMerchant,Integer codeCount) {
		Map<String, Object> map = new HashMap<>();
		HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
		if (codeCount !=15 && codeCount!=25) {
			map.put("status",  BusinessStatus.FAIL);
			map.put("msg", "升级码输入错误");
			return map;
		}
		
		try {
			HatchetMerchant merchant = hatchetMerchantService.selectHatchetMerchantById(hatchetMerchant.getID());
			if (StringUtils.isNotNull(merchant)) {
				if ("3".equals(merchant.getLEVEL())) {
					map.put("status",  BusinessStatus.FAIL);
					map.put("msg", "该用户已经是经纪人无需升级");
					return map;
				}
				if (StringUtils.isEmpty(merchant.getIdCardNumber())) {
					map.put("msg", "该用户未实名认证,请先认证后再升级");
					map.put("status", BusinessStatus.FAIL);
					return map;
				}
				// 给商户升级
				if (!merchant.getIdCardNumber().equals(agent.getIdCardNo())) {
					// 判断agentId用户的代理商id是否是自己
					if (!agent.getID().equals(merchant.getAgentId())) {
						map.put("msg", "该用户的代理商不是您");
						map.put("status", BusinessStatus.FAIL);
						return map;
					}
					// 通过身份证号查询代理商的用户身份
					HatchetMerchant paramMerchant = new HatchetMerchant();
					paramMerchant.setIdCardNumber(agent.getIdCardNo());
					List<HatchetMerchant> agentMerchantList = hatchetMerchantService
							.selectHatchetMerchantList(paramMerchant);
					boolean flag = false;
					// 一个身份证可能有多个用户账号
					if (StringUtils.isNotEmpty(agentMerchantList)) {
						// 判断待升级的用户的推荐人手机号是否和代理商的手机号一致
						for (HatchetMerchant hatchetMerchant2 : agentMerchantList) {
							// 如果代理商用户的手机号和带升级用户的推荐人手机号一致，说明是代理商的直推用户
							if (merchant.getParentPhone().equals(hatchetMerchant2.getPHONE())) {
								flag = true;
							}
						}
					}
					// 是直推用户
					if (!flag) {
						map.put("msg", "该用户不是您的直推用户");
						map.put("status", BusinessStatus.FAIL);
						return map;
					}
				}
			} else {
				map.put("msg", "该用户没找到");
				map.put("status", BusinessStatus.FAIL);
				return map;
			}
			// 如果是给自己升级经纪人要修改自己的agentId把自己的代理商换成自己
			hatchetMerchant.setAgentId(agent.getID());
			map = hatchetMerchantService.doLiftMerchant(hatchetMerchant,codeCount);
			if (BusinessStatus.SUCCESS.equals(map.get("status"))) {
				String params = "uid="+hatchetMerchant.getID()+"&sign="+StringUtils.getSign();
				String result = HttpUtils.sendGet(Constans.REFRESH_MER_URL, params);
				/*if (StringUtils.isEmpty(result)) {
					throw new RuntimeException("刷新用户信息到缓存失败导致用户修改失败,请稍后再试");
				}
				JSONObject fromObject = JSONObject.fromObject(result);
				if ("0".equals(fromObject.getString("apistatus"))) {
					throw new RuntimeException("刷新用户信息到缓存失败导致用户修改失败,请稍后再试");
				}*/
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("status", BusinessStatus.FAIL);
			map.put("msg", e.getMessage());
			return map;
		}
		return map;
	}

	/**
	 * 从配置表获取升级经纪人所需的升级码数量
	 * @param hatchetMerchant  用户
	 * @param agentId代理商
	 * @return
	 */
	@RequiresPermissions("system:hatchetMerchant:list")
	@GetMapping("/getUpgradeCodeCountForJJR")
	@ResponseBody
	public Integer getUpgradeCodeCountForJJR(HatchetMerchant hatchetMerchant) {
		return hatchetMerchantService.getUpgradeCodeCountForJJR();

	}
	
	/**
	 * 给经纪人按照收益排序  （间接：所有）
	 * @param hatchetMerchant
	 * @return
	 */
	@RequiresPermissions("system:hatchetMerchant:list")
	@PostMapping("/sortJJR")
	@ResponseBody
	public List<HatchetMerchant> sortJJR(HatchetMerchant hatchetMerchant) {
 		HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
 		if (StringUtils.isNotEmpty(hatchetMerchant.getStartTime())) {
 			hatchetMerchant.getParams().put("beginTime", hatchetMerchant.getStartTime());
		}
 		if (StringUtils.isNotEmpty(hatchetMerchant.getEndTime())) {
 			hatchetMerchant.getParams().put("endTime", hatchetMerchant.getEndTime());
		}
 		hatchetMerchant.setDepartmentCode(StringUtils.likeDepartmentCode(agent.getDepartmentCode()));
		return hatchetMerchantService.sortJJR(hatchetMerchant);
	}
	
	/**
	 *高级经纪人修改用户备注
	 */
	@RequiresPermissions("system:hatchetMerchant:detail")
	@PostMapping("/edit")
	@ResponseBody
	public Map<String, Object> editSave(HatchetMerchant hatchetMerchant) {
		Map<String, Object> map = hatchetMerchantService.editSave(hatchetMerchant);
		return map;
	}
	
}
